const fs = require("fs")
const path = require("path")
const Router = require("koa-router")
const send = require("koa-send")
const router = new Router()

router
    .get("/testDownload", async ctx => {
        ctx.type = "text/html"
        return ctx.body = "<h4> link is ok in download.js get /testDownload </h4>"
    })
    .post("/download/:name", async ctx => {
        const name = ctx.params.name
        const p = path.resolve(`upload${name}`)
        ctx.attachment(p)
        await send(ctx, p)
    })

module.exports = router